#pragma once
#ifndef skyFile_h__
#define skyFile_h__

#include "./skyAdapter.h"
#ifdef _SYMBIAN
#include "./adapter/symbian/symFile.h"
#elif defined(_WIN_)
#include "../adapter/windows/winFile.h"
#elif defined(_WIN_)
#include "../adapter/gles/osFile.h"
#endif

#include "./skyString.h"
namespace Sky
{
	
	class OSDiskManager;
	typedef RefPtr<OSDiskManager> DiskManagerPtr;

	class File : public OSFile
	{
	public:
		File();
		 ~File();

		 enum OpenMode {
			modeRead =          0x0000,
			modeWrite =         0x0001,
			modeReadWrite =     0x0002,
			modeCreate =		0x8000
		};

		enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };

		Bool   open(String* name,OpenMode flag) ;

		virtual void    close() ;
		
		i32 read(u8* lpBuf, u32 nCount);

		i32 write(const u8* lpBuf, u32 nCount);

		Bool seek(i32 lOff, u32 nFrom);

		u32 getLength() const;

		Bool   seekToBegin() ;

		Bool   seekToEnd() ;

		static Bool  deleteFile(String* name);

		static Bool  deleteDirectory(String* dir);

		static i32  getCurrentDiskFreeSpace();

		String*     getName(){return _name;}
		Bool	    isOpened(){return _bOpen;}
	protected:
		Bool		_bOpen ;
		StringPtr	_name;
	};
	typedef RefPtr<File> FilePtr;

	class DiskManager : public OSDiskManager
	{
		FilePtr createFile(String* name,File::OpenMode flag = File::modeReadWrite);
		Bool	deleteFile(String* name);
	};
}
#endif // skyFile_h__
